package com.wc.AlgoOJ_homework.aloj练习赛.H_涂色;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/5/8 23:24
 * @description http://43.138.190.70:8888/p/GDCPC6
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 55, P = 1000000007;
    static char[] s = new char[N];
    static char[] t = new char[N];
    // f[i][j][k] i 表示前面是什么样子的，j表示k涂色j的种类，i = 0表示前面是横着的， i = 1表示前面是竖着的
    /**
     * i = 1, j = 1,2,3表示红黄蓝
     * i = 0, 上下
     * j = 1表示红黄
     * j = 2表示红蓝
     * j = 3表示黄蓝
     * j = 4表示蓝红
     * j = 5表示黄红
     * j = 6表示蓝黄
     */
    static int[][][] f = new int[2][10][N];
    static int n;

    public static void main(String[] args) {
        n = sc.nextInt();
        s = (" " + sc.next()).toCharArray();
        t = (" " + sc.next()).toCharArray();

        int pre;
        if (s[1] == t[1]) {
            f[1][1][1] = f[1][2][1] = f[1][3][1] = 1;
            pre = 2;
        } else {
            f[0][1][2] = f[0][2][2] = f[0][3][2] = f[0][4][2] = f[0][5][2] = f[0][6][2] = 1;
            pre = 3;
        }
        for (int i = pre; i <= n; i++) {
            if (s[i] == t[i]) {
                f[1][1][i] = ((f[0][3][i - 1] + f[0][6][i - 1]) % P + (f[1][2][i - 1] + f[1][3][i - 1]) % P) % P;
                f[1][2][i] = ((f[0][2][i - 1] + f[0][4][i - 1]) % P + (f[1][1][i - 1] + f[1][3][i - 1]) % P) % P;
                f[1][3][i] = ((f[0][1][i - 1] + f[0][5][i - 1]) % P + (f[1][2][i - 1] + f[1][1][i - 1]) % P) % P;
            } else {
                i++;
                f[0][1][i] = ((f[0][3][i - 2] + f[0][4][i - 2]) % P + (f[0][5][i - 2] + f[1][3][i - 2]) % P) % P;
                f[0][2][i] = ((f[0][4][i - 2] + f[0][5][i - 2]) % P + (f[0][6][i - 2] + f[1][2][i - 2]) % P) % P;
                f[0][3][i] = ((f[0][1][i - 2] + f[0][4][i - 2]) % P + (f[0][6][i - 2] + f[1][1][i - 2]) % P) % P;
                f[0][4][i] = ((f[0][1][i - 2] + f[0][2][i - 2]) % P + (f[0][3][i - 2] + f[1][2][i - 2]) % P) % P;
                f[0][5][i] = ((f[0][1][i - 2] + f[0][2][i - 2]) % P + (f[0][6][i - 2] + f[1][3][i - 2]) % P) % P;
                f[0][6][i] = ((f[0][2][i - 2] + f[0][3][i - 2]) % P + (f[0][5][i - 2] + f[1][1][i - 2]) % P) % P;
            }
        }
        int res = 0;
        if (s[n] == t[n]) {
            for (int i = 1; i <= 3; i++) res = (res + f[1][i][n]) % P;
        } else {
            for (int i = 1; i <= 6; i++) res = (res + f[0][i][n]) % P;
        }
        out.println(res);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}